﻿#Region "Copyright"

' Copyright 2007 Ben Reichelt - http://benreichelt.net
' 
' Licensed under the Apache License, Version 2.0 (the "License");
' you may not use this file except in compliance with the License.
' You may obtain a copy of the License at
' 
'     http://www.apache.org/licenses/LICENSE-2.0
' 
' Unless required by applicable law or agreed to in writing, software
' distributed under the License is distributed on an "AS IS" BASIS,
' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
' See the License for the specific language governing permissions and
' limitations under the License.


#End Region

Public Class RenameTableTask
    Inherits BaseMetaDataTask

    Private _table As String
    Private _newName As String

    Public Sub New(ByVal table As String, ByVal newTableName As String, ByVal sortOrder As Integer)
        Me.Table = table
        Me.NewTableName = newTableName
        Me.SortOrder = sortOrder
    End Sub

    Public Overrides Sub Execute(ByVal metaData As XmlMetaData, ByVal context As AppContext)
        MyBase.Execute(metaData, context)
        metaData.FindTable(Table).RenameTo(NewTableName)
    End Sub

    Public Overrides ReadOnly Property LogMessage() As String
        Get
            Return String.Format("Renaming Table ""{0}"" to ""{1}""", Table, NewTableName)
        End Get
    End Property

    Public Property Table() As String
        Get
            Return _table
        End Get
        Protected Set(ByVal value As String)
            _table = value
        End Set
    End Property

    Public Property NewTableName() As String
        Get
            Return _newName
        End Get
        Protected Set(ByVal value As String)
            _newName = value
        End Set
    End Property

End Class
